Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Conversation

jose-carmona
Copy link

Support for Dependency Injection based on Injector.

Example

Provider:

class AppModule(Module):
    @provider
    @singleton
    def provide_str(self) -> str:
        return 'TEST INJECTED'

    @provider
    @singleton
    def provide_int(self) -> int:
        return 42

Init:

app = Flask(__name__)
module = AppModule()
injector = Injector([module])
assist = Assistant(app, project_id="test-project-id", injector=injector)

Dependency Injection in action decorator:

@assist.context("context_1")
@assist.action("intent_with_context_injects_params")
@inject
def intent_with_context_injects_params(speech: str, p1, p2, i: int):
    return ask("context_1:" +speech + ":" + p1 + ":" + p2 + ":" +str(i))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant